<template>
    <div class="makerList">
        <div class="makerList_top">
			<div class="into_index">首页<i class="el-icon-close"></i></div>
			<div class="current">导购订单<i class="el-icon-close"></i></div>
		</div>
        <div class="makerList_bottom">
            <div class="new">
                <div class="shopList">
                    <div class="shopList_serch">
                        <div class="shopClass">
                            <!-- <div>
                                <span>订单类型</span>
                                <div class="block">
                                   <el-select v-model="valueType" @change="orderType" placeholder="请选择">
										<el-option
										v-for="item in makerType"
										:key="item.type_id"
										:label="item.type_name"
										:value="item.type_id">
										</el-option>
									</el-select>
                                </div>
                            </div> -->
                            <div>
                                <span>订单状态</span>
                                <div class="block">
                                   <el-select v-model="valueStatus" @change="orderStatus" placeholder="请选择">
										<el-option
										v-for="item in makerStatus"
										:key="item.status_id"
										:label="item.status_name"
										:value="item.status_id">
										</el-option>
									</el-select>
                                </div>
                            </div>
                        </div>
                        <div class="shopList_serch_ipt">
							<el-input v-model="input" placeholder="请输入商品信息查询"></el-input>
							<button @click="handerSeach"><i class="el-icon-search"></i>搜索</button>
						</div>
                    </div>
                </div>
            </div>
            
            <div class="makerList_table">
                <div class="makerList_bottom_table">
					<table>
						<tr>
							<th></th>
							<th>序号</th>
							<!-- <th>类型</th> -->
							<th>分销精英</th>
							<th>预计佣金</th>
							<th>买家昵称</th>
							<th>下单时间</th>
							<th>订单状态</th>
							<!-- <th>操作</th> -->
						</tr>
						<tr v-for="(v,i) in tableList" :key="i">
							<td>
								<font class="checkbox" :class="{'check_active' : checkBoxAll.includes(i)}" @click="handlerCheckbox(i)"><i class="el-icon-check"></i></font>
							</td>
							<td>{{v.id}}</td>
							<!-- <td>{{v.type==1?'商城订单':v.type==2?'设计订单':v.type==3?'施工订单':''}}</td> -->
							<td>{{v.guide_realname}}</td>
							<td>{{v.parent_commission}}</td>
							<td>{{v.nickname}}</td>
							<td>{{$moment(v.create_time*1000).format('yyyy-MM-DD')}}</td>
							<td>
								<p v-if="v.arrival_time>0">可提现</p>
								<p v-else-if="v.finish_time>0">已完成</p>
								<p v-else-if="v.pay_time>0">已付款</p>
								<p v-else>未完成</p>
							</td>
							<!-- <td>
								<button class="editor" @click="toDel(v.account_id)">详情</button>
								<button class="shelves" @click="toDel(v.account_id)">取消订单</button>
							</td> -->
						</tr>
						<tr v-if="tableList.length == 0"><td class="table_title" colspan="12">当前数据空空如也</td></tr>
					</table>
				</div>
				<div class="makerList_bottom_page">
				<div class="makerList_bottom_page_left">
					<div class="makerList_bottom_page_left_checkAll" @click="handerCheckAll">
						<font class="checkbox" :class="{'check_active' : checkAll}"><i class="el-icon-check"></i></font>
					</div>全选
					<!-- <button class="busineList_bottom_page_left_btn" @click="selectDel">删除</button> -->
					</div>
					<div class="makerList_bottom_page_right">
						<el-pagination
							@size-change="handleSizeChange"
							@current-change="handleCurrentChange"
							:current-page="page"
							:page-sizes="[10, 20, 30, 40]"
							:page-size="pageSize"
							layout="total, sizes, prev, pager, next, jumper"
							:total="total"
							background>
						</el-pagination>
					</div>
				</div>
            </div>
        </div>
    </div>
</template>

<script>
import api from '@/api/index.js'
export default {
    data(){
        return{
            // 类型
            makerType:[
                {type_name:'全部',type_id:1},
                {type_name:'商城订单',type_id:2},
                {type_name:'施工订单',type_id:3},
                {type_name:'设计订单',type_id:4},
               ],
			   valueType:null,

            // 状态
            makerStatus:[
                {status_name:'全部',status_id:1},
                {status_name:'已付款',status_id:2},
                {status_name:'已完成',status_id:3},
                {status_name:'可提现',status_id:4},
                {status_name:'未完成',status_id:5},
               ],
			   valueStatus:1,

            tableList:[{}],
            input:'',
			checkAll:false,
			page:1,
			pageSize:10,
			total:0,
            checkBoxAll:[],				// 选中的数据
			shelvesAlls:[],
        }
    },
	mounted(){
		this.getGuideList()
	},
    methods: {
		// 获取导购订单列表
		getGuideList(){
			api.guideList({page:this.page,pagesize:this.pageSize,type:this.valueStatus}).then(res=>{
				console.log(res);
				if(res.code==1){
					this.tableList = res.data.list?res.data.list:[]
					this.total = res.data.total
				}
			})
		},

		// 选择订单类型
		orderType(e){
			console.log(e);
		},

		// 选择订单状态
		orderStatus(e){
			console.log(e);
			this.getGuideList()
		},

         // 多选
			handlerCheckbox(i){
                console.log(i);
				let arr = this.checkBoxAll;
				if(arr.includes(i)){
					let index = arr.indexOf(i);
					if(index > -1){
						arr.splice(index,1);
						if(this.checkBoxAll.length !== this.tableList.length) {
							this.checkAll = false;
						}
					}
				}else {
					this.checkBoxAll.push(i);
					if(this.checkBoxAll.length == this.tableList.length) {
						this.checkAll = true;
					}
				};
				this.shelvesAlls.push(this.tableList[i].product_id);
				console.log(this.shelvesAlls);
			},
            // 全选与全不选
			handerCheckAll(){
				this.checkAll = !this.checkAll;
				let arr = this.tableList.length;
				this.checkBoxAll = [];
				if(this.checkAll){
					for(let i=0;i<arr;i++){
						this.checkBoxAll.push(i);
					}
				}else {
					this.checkBoxAll = [];
				}
				// 去重
				let res = this.checkBoxAll;
				for(let i=0;i<res.length;i++){
					for(let j=i+1;j<res.length;j++) {
						if(res[i] == res[j]) {
							res.splice(j,1);
							j--;
						}
					}
				};
				this.checkBoxAll.map(v => {
					return this.shelvesAlls.push(this.tableList[v].store_id.toString());;
				})
				
				console.log(this.shelvesAlls);
			},

        // 搜索
        handerSeach(){},

        handleChange1(){},
        handleChange2(){},

        //分页
			handleSizeChange(val) {
				this.pageSize = val;
				console.log(val);
				this.getGuideList()
			},
			handleCurrentChange(val) {
			    this.page = val;
				console.log(val);
				this.getGuideList()
			},
    },
}
</script>

<style lang="less" scoped>
    @import 'guideOrder.less';
</style>